<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
    xmlns:jsf="http://xmlns.jcp.org/jsf"
    xmlns:pt="http://java.sun.com/jsf/passthrough"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:o="http://omnifaces.org/ui"
    xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs">
    
    <!-- Access Status -->
    <li class="dropdown-header">#{bundle['file.accessBtn.header.access']} <span class="glyphicon glyphicon-file"/></li>
    <li><span class="dropdown-item-text">
            <span class="#{dataFileServiceBean.isRetentionExpired(fileMetadata) ? 'glyphicon glyphicon-lock text-danger' : !fileMetadata.restricted ?
                           'glyphicon glyphicon-globe text-success' : (!fileDownloadHelper.canDownloadFile(fileMetadata) ? 'glyphicon glyphicon-lock text-danger' : 'icon-unlock text-success')}"/>
            
            <!-- TODO - add Embargo state -->
            <h:outputText 
                value=" #{dataFileServiceBean.isRetentionExpired(fileMetadata) ? bundle['retentionExpired'] : !fileDownloadHelper.isRestrictedOrEmbargoed(fileMetadata) ? bundle['public'] : (!fileDownloadHelper.canDownloadFile(fileMetadata) ? (!dataFileServiceBean.isActivelyEmbargoed(fileMetadata) ? bundle['restricted'] : bundle['embargoed']) : (!dataFileServiceBean.isActivelyEmbargoed(fileMetadata) ? bundle['restrictedaccess'] : bundle['embargoed']) )}"
                styleClass="#{dataFileServiceBean.isRetentionExpired(fileMetadata) ? 'text-danger' : !fileDownloadHelper.isRestrictedOrEmbargoed(fileMetadata) ? 'text-success' : (!fileDownloadHelper.canDownloadFile(fileMetadata) ? 'text-danger' : 'text-success')}"/>
        </span></li>
    <ui:fragment rendered="#{!fileMetadata.datasetVersion.deaccessioned and !fileDownloadHelper.canDownloadFile(fileMetadata)
                             and fileMetadata.dataFile.owner.fileAccessRequest
                             and !dataFileServiceBean.isActivelyEmbargoed(fileMetadata)
                             and !dataFileServiceBean.isRetentionExpired(fileMetadata)}">
        <p:outputPanel id="requestPanel" styleClass="iq-dropdown-list-item #{fileMetadata.dataFile.containsActiveFileAccessRequestFromUser(dataverseSession.user) ? 'disabled' : ''}"
                       rendered="#{fileDownloadHelper.session.user.authenticated}">
            <p:commandLink styleClass="btn-request #{fileMetadata.dataFile.containsActiveFileAccessRequestFromUser(dataverseSession.user) ? 'italic'  : ''}"
                        actionListener="#{fileDownloadHelper.handleCommandLinkClick(fileMetadata)}"
                        update="@([id$=requestAccessConsolidated]), @([id$=requestPanel]),  @([id$=filesTable]), @([id$=messagePanel]), @([id$=guestbookAndTermsPopup])"
                        id="requestAccessConsolidated"
                        disabled="#{fileMetadata.dataFile.containsActiveFileAccessRequestFromUser(dataverseSession.user)}">
                 <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle['file.requestAccess'])}"/>
                #{fileMetadata.dataFile.containsActiveFileAccessRequestFromUser(dataverseSession.user) ? bundle['file.accessRequested'] : bundle['file.requestAccess']}
            </p:commandLink>
        </p:outputPanel>
        <li jsf:rendered="#{!fileDownloadHelper.session.user.authenticated}">
            <p:commandLink styleClass="btn-request" 
                        process="@this"
                        onclick="PF('accessSignUpLogIn_popup').show()">
                #{bundle['file.requestAccess']}
            </p:commandLink>
        </li>
    </ui:fragment>
    <ui:fragment rendered="#{!fileMetadata.datasetVersion.deaccessioned and !fileDownloadHelper.canDownloadFile(fileMetadata)
                             and !fileMetadata.dataFile.owner.fileAccessRequest and !dataFileServiceBean.isActivelyEmbargoed(fileMetadata)}">
        <li><span class="dropdown-item-text">#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.notRequest']}</span></li>
    </ui:fragment>
    <ui:fragment rendered="#{!fileMetadata.datasetVersion.deaccessioned and !fileDownloadHelper.canDownloadFile(fileMetadata)
                             and dataFileServiceBean.isActivelyEmbargoed(fileMetadata)}">
        <li><span class="dropdown-item-text">#{fileMetadata.restricted ? bundle['file.dataFilesTab.terms.list.termsOfAccess.embargoedthenrestricted'] : bundle['file.dataFilesTab.terms.list.termsOfAccess.embargoed']}</span></li>
    </ui:fragment>
    <!-- END: Request Access Options -->
    
    <!-- CAN DOWNLOAD ACCESS Options -->
    <ui:fragment rendered="#{fileDownloadHelper.canDownloadFile(fileMetadata)}">
        <!-- Download Options -->
        <li class="dropdown-header">#{bundle['file.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li>
        
        <!-- GlobusTransfer, orig file only  -->
         <o:importFunctions type="edu.harvard.iq.dataverse.dataaccess.DataAccess" />
        <li jsf:rendered="#{settingsWrapper.globusFileDownload and settingsWrapper.isGlobusTransferable(fileMetadata)}">
            <p:commandLink rendered="#{!(guestbookAndTermsPopupRequired) 
                                      and !(fileMetadata.dataFile.filePackage)}"
                         styleClass="btn-download"
                         process="@this"
                         disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                         actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'GlobusTransfer')}">
                <!-- non-tabular data file: -->
                <!-- no guest book/terms of use/etc. - straight to the download API url: -->
                <span class="globus-btn ui-icon" title="#{bundle['file.globus.transfer']}"/> #{bundle['file.globus.of']} #{fileMetadata.dataFile.friendlyType == 'Unknown' ? bundle['file.download.filetype.unknown'] : fileMetadata.dataFile.friendlyType}
            </p:commandLink>
            <p:commandLink rendered="#{guestbookAndTermsPopupRequired and !fileMetadata.dataFile.filePackage}"
                         styleClass="btn-download"
                         process="@this"
                         disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                         actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'GlobusTransfer')}"
                         update="@widgetVar(guestbookAndTermsPopup)" oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                         <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                <f:setPropertyActionListener target="#{fileMetadataForAction}" value="#{fileMetadata}" />
                <!-- guest book or terms of use, etc. enabled - open "download popup" first: -->
                <span class="globus-btn ui-icon" title="#{bundle['file.globus.transfer']}"/> #{bundle['file.globus.of']} #{fileMetadata.dataFile.friendlyType == 'Unknown' ? bundle['file.download.filetype.unknown'] : fileMetadata.dataFile.friendlyType}
            </p:commandLink>
        </li>
        
        
        <!-- NON-TABULAR + PACKAGE DOWNLOAD OPTIONS -->
        <li jsf:rendered="#{!fileMetadata.dataFile.tabularData}">
            <p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and !(guestbookAndTermsPopupRequired) 
                                    and fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload}"
                         styleClass="btn-download" process="@this"
                         disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                         update="@widgetVar(downloadPackagePopup)" oncomplete="PF('downloadPackagePopup').show();handleResizeDialog('downloadPackagePopup');">
                <f:actionListener binding="#{packagePopupFragmentBean.setFileMetadata(fileMetadata)}" />
                <f:actionListener binding="#{fileDownloadService.writeGuestbookResponseRecord(guestbookResponse, fileMetadata, 'package')}" />
                <!-- package data file: -->
                <!-- no guest book/terms of use/etc. - straight package popup -->
                #{fileMetadata.dataFile.friendlyType == 'Unknown' ? bundle['file.download.filetype.unknown'] : fileMetadata.dataFile.friendlyType}
            </p:commandLink>
            <p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and (guestbookAndTermsPopupRequired) 
                                    and fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload}"
                         styleClass="btn-download"
                         process="@this"
                         disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                         actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'package')}"
                         update="@widgetVar(guestbookAndTermsPopup)" oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                         <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                <f:actionListener binding="#{packagePopupFragmentBean.setFileMetadata(fileMetadata)}" /> 
                <!-- package data file: -->
                <!-- guest book or terms of use, etc. enabled - open "download popup" first: -->
                #{fileMetadata.dataFile.friendlyType == 'Unknown' ? bundle['file.download.filetype.unknown'] : fileMetadata.dataFile.friendlyType}
            </p:commandLink>
            <p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and !(guestbookAndTermsPopupRequired) 
                                      and !(fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload) and settingsWrapper.isDownloadable(fileMetadata)}"
                         styleClass="btn-download"
                         process="@this"
                         disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                         actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'Download')}">
                <!-- non-tabular data file: -->
                <!-- no guest book/terms of use/etc. - straight to the download API url: -->
                #{fileMetadata.dataFile.friendlyType == 'Unknown' ? bundle['file.download.filetype.unknown'] : fileMetadata.dataFile.friendlyType}
            </p:commandLink>
            <p:commandLink rendered="#{!(fileMetadata.dataFile.tabularData) and guestbookAndTermsPopupRequired 
                                      and !(fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload) and settingsWrapper.isDownloadable(fileMetadata)}"
                         styleClass="btn-download"
                         process="@this"
                         disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                         actionListener="#{guestbookResponseService.modifyDatafile(guestbookResponse, fileMetadata)}"
                         update="@widgetVar(guestbookAndTermsPopup)" oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                <f:setPropertyActionListener target="#{fileMetadataForAction}" value="#{fileMetadata}" />
                <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                <!-- guest book or terms of use, etc. enabled - open "download popup" first: -->
                #{fileMetadata.dataFile.friendlyType == 'Unknown' ? bundle['file.download.filetype.unknown'] : fileMetadata.dataFile.friendlyType}
            </p:commandLink>
        </li>
        <!-- TABULAR DOWNLOAD OPTIONS -->
        <ui:fragment rendered="#{fileMetadata.dataFile.tabularData}">
            <ui:remove>
            <li>
                <p:commandLink styleClass="highlightBold btn-download" rendered="#{!(guestbookAndTermsPopupRequired)}"
                               process="@this"
                               actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'bundle')}">
                    #{bundle['file.downloadBtn.format.all']}
                </p:commandLink>
                <p:commandLink styleClass="highlightBold btn-download" rendered="#{guestbookAndTermsPopupRequired}"
                               process="@this"
                               actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'bundle' )}"
                               update="@widgetVar(guestbookAndTermsPopup)"
                               oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                               <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                    #{bundle['file.downloadBtn.format.all']}
                </p:commandLink>
            </li>
            <li role="presentation" class="divider"></li>
            </ui:remove>
            <li>
                <p:commandLink styleClass="btn-download" rendered="#{!guestbookAndTermsPopupRequired and !(fileMetadata.dataFile.originalFormatLabel == 'UNKNOWN')}"
                               process="@this"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                               actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'original')}">
                    <h:outputFormat value="#{bundle['file.downloadBtn.format.original']}">
                        <f:param value="#{fileMetadata.dataFile.originalFormatLabel}"/>
                    </h:outputFormat>
                </p:commandLink>
                <p:commandLink styleClass="btn-download" rendered="#{guestbookAndTermsPopupRequired and !(fileMetadata.dataFile.originalFormatLabel == 'UNKNOWN')}"
                               process="@this"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                               actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'original' )}"
                               update="@widgetVar(guestbookAndTermsPopup)"
                               oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                    <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                    <f:setPropertyActionListener target="#{fileMetadataForAction}" value="#{fileMetadata}" />
                    <h:outputFormat value="#{bundle['file.downloadBtn.format.original']}">
                        <f:param value="#{fileMetadata.dataFile.originalFormatLabel}"/>
                    </h:outputFormat>
                </p:commandLink>
            </li>
            <li>
                <p:commandLink styleClass="btn-download" rendered="#{!guestbookAndTermsPopupRequired}"
                               process="@this"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                               actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'tab')}">
                    #{bundle['file.downloadBtn.format.tab']}
                </p:commandLink>
                <p:commandLink styleClass="btn-download" rendered="#{guestbookAndTermsPopupRequired}"
                               actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'tab' )}"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                               update="@widgetVar(guestbookAndTermsPopup)"
                               oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                    <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                    <f:setPropertyActionListener target="#{fileMetadataForAction}" value="#{fileMetadata}" />
                    #{bundle['file.downloadBtn.format.tab']}
                </p:commandLink>
            </li>
            <ui:fragment rendered="#{!(fileMetadata.dataFile.originalFormatLabel == 'RData')}">
                <li>
                    <p:commandLink styleClass="btn-download" rendered="#{!guestbookAndTermsPopupRequired}"
                                   process="@this"
                                   disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                                   actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'RData')}">
                        #{bundle['file.downloadBtn.format.rdata']}
                    </p:commandLink>
                    <p:commandLink styleClass="btn-download" rendered="#{guestbookAndTermsPopupRequired}"
                                   process="@this"
                                   disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                                   actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'RData' )}"
                                   update="@widgetVar(guestbookAndTermsPopup)"
                                   oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                        <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                        <f:setPropertyActionListener target="#{fileMetadataForAction}" value="#{fileMetadata}" />
                        #{bundle['file.downloadBtn.format.rdata']}
                    </p:commandLink>
                </li>
            </ui:fragment>
        </ui:fragment>
        <!-- END: TABULAR DOWNLOAD OPTIONS -->
    </ui:fragment>
    <!-- END: CAN DOWNLOAD ACCESS Options -->
    
    <!-- Download Metadata -->
    <li class="dropdown-header">#{bundle['file.accessBtn.header.metadata']} <span class="glyphicon glyphicon-download-alt"/></li>
    
    <ui:fragment rendered="#{fileMetadata.dataFile.tabularData and fileDownloadHelper.canDownloadFile(fileMetadata)}">
        <li>
            <p:commandLink styleClass="btn-download" rendered="#{!guestbookAndTermsPopupRequired}"
                           process="@this"
                           disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                           actionListener="#{fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse, fileMetadata, 'var')}">
                #{bundle['file.downloadBtn.format.var']}
            </p:commandLink>
            <p:commandLink styleClass="btn-download" rendered="#{guestbookAndTermsPopupRequired}"
                           process="@this"
                           disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}" 
                           actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'var' )}"
                           update="@widgetVar(guestbookAndTermsPopup)"
                           oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                           <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                #{bundle['file.downloadBtn.format.var']}
            </p:commandLink>
        </li>
    </ui:fragment>
    
    <!-- CITATION FILES DOWNLOAD OPTIONS -->
    <li class="dropdown-submenu pull-left" jsf:rendered="#{!anonymized}">
            <a tabindex="0">#{bundle['file.downloadBtn.format.citation']}</a>
        <ul class="dropdown-menu">
            <li>
                <h:commandLink styleClass="btn-download" action="#{fileDownloadService.downloadDatafileCitationXML(fileMetadata)}">
                    <h:outputText value="#{bundle['dataset.cite.downloadBtn.xml']}" />
                </h:commandLink>
            </li>
            <li>
                <h:commandLink styleClass="btn-download" actionListener="#{fileDownloadService.downloadDatafileCitationRIS(fileMetadata)}">
                    <h:outputText value="#{bundle['dataset.cite.downloadBtn.ris']}" />
                </h:commandLink>
            </li>
            <li>
                <h:commandLink styleClass="btn-download" action="#{fileDownloadService.downloadDatafileCitationBibtex(fileMetadata)}">
                    <h:outputText value="#{bundle['dataset.cite.downloadBtn.bib']}" />
                </h:commandLink>
            </li>
        </ul>
    </li>
    <!-- UI HACK FIX SUBMENU PULL-FLOAT FIX -->
    <li role="presentation" class="clearfix"></li>
    <!-- END: CITATION FILES DOWNLOAD OPTIONS -->
    
    <!-- TODO - looks like this shows Aux files regardless of whether you can download them but the redirect to the API will check permissions downloads related to unreleased files and non-public aux files on files that are restricted/embargoed. Should the menu indicate the restrictions?  -->
    <!-- AUX FILES DOWNLOAD OPTIONS -->
    <ui:fragment rendered="#{not empty auxiliaryFileServiceBean.findAuxiliaryFiles(fileMetadata.dataFile)}">
        <!-- Download Auxiliary Files -->
        <li class="dropdown-header">#{bundle['file.auxfiles.download.header']} <span class="glyphicon glyphicon-download-alt"/></li>
        <!-- Aux Files in Bundle (DP, etc.)-->
        <ui:repeat var="auxFileType" value="#{auxiliaryFileServiceBean.findAuxiliaryFileTypes(fileMetadata.dataFile, true)}">
            <li class="dropdown-submenu pull-left">
                <a tabindex="0">#{auxiliaryFileServiceBean.getFriendlyNameForType(auxFileType)}</a>
                <ul class="dropdown-menu">
                    <ui:repeat var="auxFile" value="#{auxiliaryFileServiceBean.findAuxiliaryFilesByType(fileMetadata.dataFile, auxFileType)}">
                        <li>
                            <p:commandLink styleClass="btn-download" action="#{fileDownloadService.redirectToAuxFileDownloadAPI(fileMetadata.dataFile.id, auxFile.formatTag, auxFile.formatVersion)}">
                                <h:outputText value="#{auxFile.formatTag} (#{auxFile.formatVersion})"/>
                            </p:commandLink>
                        </li>
                    </ui:repeat>
                </ul>
            </li>
        </ui:repeat>
        <!--Other Aux Files (not in bundle)-->
        <li class="dropdown-submenu pull-left" jsf:rendered="#{not empty auxiliaryFileServiceBean.findOtherAuxiliaryFiles(fileMetadata.dataFile)}">
            <a tabindex="0">#{bundle['file.auxfiles.unspecifiedTypes']}</a>
            <ul class="dropdown-menu">
                <ui:repeat var="auxFile" value="#{auxiliaryFileServiceBean.findOtherAuxiliaryFiles(fileMetadata.dataFile)}">
                    <li>
                        <p:commandLink styleClass="btn-download" action="#{fileDownloadService.redirectToAuxFileDownloadAPI(fileMetadata.dataFile.id, auxFile.formatTag, auxFile.formatVersion)}">
                            <h:outputText value="#{auxFile.formatTag} (#{auxFile.formatVersion})"/>
                        </p:commandLink>
                    </li>
                </ui:repeat>
            </ul>
        </li>
        <!-- UI HACK FIX SUBMENU PULL-FLOAT FIX -->
        <li role="presentation" class="clearfix"></li>
    </ui:fragment>
    <!-- END: Download Auxiliary Files -->
    <!-- END: AUX FILES DOWNLOAD OPTIONS -->
    
    <!-- Explore Options -->
    <ui:fragment rendered="#{fileDownloadHelper.canDownloadFile(fileMetadata) and not empty exploreTools}">
        <!--exploreTools is set as a ui:param by the file and dataset pages-->
        <li class="dropdown-header">#{bundle['dataset.accessBtn.header.explore']} <span class="glyphicon glyphicon-equalizer"/></li>
        <!-- externalTools -->
        <ui:repeat var="tool" value="#{exploreTools}">
            <li>
                <p:commandLink rendered="#{!guestbookAndTermsPopupRequired}"
                               styleClass="btn-explore #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
                               action="#{fileDownloadService.explore(guestbookResponse, fileMetadata, tool )}">
                    #{tool.getDisplayNameLang()}
                </p:commandLink>
                <!--The modifyDatafileAndFormat method below was added because on the dataset page, "tool" is null in the popup so we store it in the guestbookResponse because we know we'll need it later in the popup.-->
                <p:commandLink rendered="#{guestbookAndTermsPopupRequired}"
                               actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'externalTool', tool)}"
                               styleClass="btn-explore #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload)}"
                               process="@this"
                               update="@widgetVar(guestbookAndTermsPopup)"
                               oncomplete="PF('guestbookAndTermsPopup').show();handleResizeDialog('guestbookAndTermsPopup');">
                               <f:actionListener binding="#{bean.setTermsGuestbookPopupAction(bundle.download)}"/>
                    #{tool.getDisplayNameLang()}
                </p:commandLink>
            </li>
        </ui:repeat>
        <!-- END: externalTools -->
    </ui:fragment>
    
    
    <!-- Query Options -->
    <ui:fragment rendered="#{fileDownloadHelper.canDownloadFile(fileMetadata) and not empty queryTools}">
        <!--query Tools is set as a ui:param by the file and dataset pages-->
        <li class="dropdown-header">#{bundle['file.accessBtn.header.query']} <span class="glyphicon glyphicon-equalizer"/></li>
        <!-- query Tools -->
        <ui:repeat var="tool" value="#{queryTools}">
            <li>
                <p:commandLink rendered="#{!downloadPopupRequired}"
                               styleClass="btn-query #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
                               action="#{fileDownloadService.explore(guestbookResponse, fileMetadata, tool )}">
                    #{tool.getDisplayNameLang()}
                </p:commandLink>
                <!--The modifyDatafileAndFormat method below was added because on the dataset page, "tool" is null in the popup so we store it in the guestbookResponse because we know we'll need it later in the popup.-->
                <p:commandLink rendered="#{downloadPopupRequired}"
                               actionListener="#{guestbookResponseService.modifyDatafileAndFormat(guestbookResponse, fileMetadata, 'externalTool', tool)}"
                               styleClass="btn-query #{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload) ? 'disabled' : ''}"
                               disabled="#{(fileMetadata.dataFile.ingestInProgress or lockedFromDownload)}"
                               process="@this"
                               update="@widgetVar(downloadPopup)"
                               oncomplete="PF('downloadPopup').show();handleResizeDialog('downloadPopup');">
                    #{tool.getDisplayNameLang()}
                </p:commandLink>
            </li>
        </ui:repeat>
        <!-- END: externalTools -->
    </ui:fragment>
    <!-- Compute Options -->
    <ui:fragment rendered="#{(isFilePg ? FilePage.showComputeButton() : DatasetPage.showComputeButton(fileMetadata)) and fileDownloadHelper.canDownloadFile(fileMetadata)}">
        <li class="dropdown-header">#{bundle['dataset.accessBtn.header.compute']} <span class="glyphicon glyphicon-flash"/></li>
        <li>
            <h:outputLink value="#{isFilePg ? FilePage.computeUrl : DatasetPage.getComputeUrl(fileMetadata)}" styleClass="btn-compute" 
                          target="_blank" rel="noopener">
                #{bundle['file.compute']}
            </h:outputLink>
        </li>
    </ui:fragment>
    <!-- END: Compute Options -->
</ui:composition>
